/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.circuitrunners.frc2011;
import edu.wpi.first.wpilibj.*;
/**
 *
 * @author Anupam
 */

/*
 * This isn't really a handler, more of a processor
 * makes everything easy (no messy calling of joysticks), centralizes the joysticks,
 * makes everything more efficient too because everything is static (no constant updating)
 */
public class IOHandler {
    private static final Joystick LEFT_DRIVE = new Joystick(2);
    private static final Joystick RIGHT_DRIVE = new Joystick(3);
    private static final Joystick XBOX_360 = new Joystick(1);
    private static final DigitalInput DI_14 = new DigitalInput(14), DI_13 = new DigitalInput(13), DI_1 = new DigitalInput(1),
            DI_2 = new DigitalInput(2), DI_3 = new DigitalInput(3);
    
    /**
     * Gets the boolean value of each digital input's current setting
     * @param di - the DigitalInput in question
     * @return the boolean value of the digital input's current setting     
     */
    public static boolean getDigitalInput(int di){
        switch(di){
            case 1:
                return DI_1.get();
            case 2:
                return DI_2.get();
            case 3:
                return DI_3.get();
            case 14:
                return DI_14.get();
            case 13:
                return DI_13.get();
            default:
                return false;
        }
    }
    /**
     * Get the value of a button on the left Joystick
     * @param the button number
     * @return the state of the button
     */
     public static boolean getLeftButton(int button){
         return LEFT_DRIVE.getRawButton(button);
     }
    /**
     * Get the value of a button on the right Joystick
     * @param the button number
     * @return the state of the button
     */
    public static boolean getRightButton(int button){
         return RIGHT_DRIVE.getRawButton(button);
    }
    /**
     * Get the Left Joystick's X axis
     * @return the value the left x axis is at
     */
    public static double getLeftX(){
        return LEFT_DRIVE.getRawAxis(1);
    }
    public static final int LEFT = 1;
    public static final int RIGHT = 2;
    public static double getDriveAxis(int joystick, int axis){
        Joystick wantedJoystick = new Joystick(9);
        switch(joystick){
            case LEFT: wantedJoystick = LEFT_DRIVE; break;
            case RIGHT: wantedJoystick = RIGHT_DRIVE; break;
        }
        return wantedJoystick.getRawAxis(axis);
    }
    /**
     * Get the Right Joystick's X axis
     * @return the value of the Right X Axis
     */
    public static double getRightX(){
           return RIGHT_DRIVE.getRawAxis(1);
    }
    /**
     * Get the Value of the Y axis on the left Joystick
     * @return the value that is currently on the Y axis of the Left Joystick
     */
    public static double getLeftY(){
        return LEFT_DRIVE.getRawAxis(2);
    }
    /**
     * Get the Value of the Y axis on the right Joystick
     * @return the value of the Y axis on the Right Joystick
     */
    public static double getRightY(){
       return RIGHT_DRIVE.getRawAxis(2);
    }
    /**
     * Get the value of the Z axis on the Right Joystick
     * @return the value of the Z Axis on the Right Joystick
     */
    public static double getRightZ(){
        return RIGHT_DRIVE.getRawAxis(3);
    }
    /**
     * Get the Value of the Throttle on the Left Joystick
     * @return the value of the Throttle on the Left Joystick
     */
    public static double getLeftThrottle(){
        return LEFT_DRIVE.getThrottle();
    }
    /**
     * Get the value of the throttle on the Right Joystick
     * @return the Throttle on the right Joystick
     */
    public static double getRightThrottle(){
        return RIGHT_DRIVE.getThrottle();
    }
    /**
     * Get the state of a button on the Xbox Controller
     * @param the button number
     * @retun the state of a button on the XBOX controller
     */
    public static boolean getXBOX_BUTTON(int button){
        return XBOX_360.getRawButton(button);
    }
    /**
     * Get the value of an axis on the XBOX contoller
     * @param the Axis number
     * @return the value of the axis specified on the xbox controller;
     */
    public static double getXBOX_AXIS(int axis){
        return XBOX_360.getRawAxis(axis);
    }
}

